<!--
<script>
	import Footer from '@/components/Footer.vue';
	
	export default{
		name:'BusinessList',
		data(){
			return{
				orderTypeId:this.$route.query.orderTypeId,
				businessArr:[]
			}
		},
		created(){
			//根据orderTypeId查询商家信息
			this.$axios.post('BusinessController/listBusinessByOrderTypeId',this.$qs.stringify({
				orderTypeId:this.orderTypeId
			})).then(response=>{
				this.businessArr = response.data;
			}).catch(error=>{
				console.error(error);
			});
			
		},
		components:{
			Footer
		},
		methods:{
			toBusinessInfo(businessId){
				this.$router.push({path:'/businessInfo',query:{businessId:businessId}});
			}
		}
	}
</script>
-->
<script>
import { ref, onMounted } from 'vue';
import Footer from '@/components/Footer.vue';

export default {
  name: 'BusinessList',
  components: {
    Footer
  },
  setup() {
    const orderTypeId = ref(this.$router.query.orderTypeId);
    const businessArr = ref([]);

    const toBusinessInfo = (businessId) => {
      this.$router.push({ path: '/businessInfo', query: { businessId: businessId } });
    };

    onMounted(() => {
      fetchBusinessData();
    });

    const fetchBusinessData = () => {
      this.$axios
        .post('BusinessController/listBusinessByOrderTypeId', this.$qs.stringify({ orderTypeId: orderTypeId.value }))
        .then(response => {
          businessArr.value = response.data;
        })
        .catch(error => {
          console.error(error);
        });
    };

    return {
      orderTypeId,
      businessArr,
      toBusinessInfo
    }
  },
}
</script>